<template>
  <basic-container>
    <avue-crud :option="option"
               :table-loading="loading"
               :data="data"
               ref="crud"
               v-model="form"
               :defaults.sync="showColumn"
               :permission="permissionList"
               :page.sync="page"
               :before-open="beforeOpen"
               @sortable-change="sortableChange"
               @row-del="rowDel"
               @row-update="rowUpdate"
               @row-save="rowSave"
               @refresh-change="refreshChange"
               @search-change="searchChange"
               @search-reset="searchReset"
               @selection-change="selectionChange"
               @current-change="currentChange"
               @size-change="sizeChange"
               @filter="filterChange"
               @sort-change="sortChange"
               @row-dblclick="handleRowDBLClick"               
               @on-load="onLoad">
      <template slot-scope="scope" slot="menu">
        <el-button v-if="functionType == 'add'" type="text"
                   size="small"
                   icon="el-icon-sort"
                   @click.stop="addToBizFunctionList(scope.row)">添加
        </el-button>
        <el-button v-if="functionType == 'version2'" type="text"
                   size="small"
                   icon="el-icon-sort"
                   @click.stop="changeBizFunctionVersion(scope.row)">切换此版本
        </el-button>
      </template>
      <template slot-scope="scope" slot="assetFlag">
            <div>
              <el-tag v-if="scope.row.assetFlag == '0'" type="info">否</el-tag>
              <el-tag v-if="scope.row.assetFlag == '1'" type="success">是</el-tag>
            </div>
      </template>
    </avue-crud>
    <!-- 
      批量添加数据对话框
     -->
    <el-dialog title="批量导入" width='80%' :close-on-click-modal='false' :visible.sync="batchAddDialog">
      <el-tag>
		业务场景编号，
		业务功能点编号，
		版本号，
		资产标志，
		业务场景名称，
		业务功能点名称，
		业务功能点类型，
		处理方式，
		业务序号，
		业务功能点描述，
		变更时间，
		业务功能点状态，
      </el-tag>
      <el-input
        type="textarea"
        :autosize="{ minRows: 10, maxRows: 20}"
        placeholder="请直接从excel粘贴内容"
        v-model="importDataArea">
      </el-input>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" id="copyBtn" @click="handleImport($event)" data-clipboard-target="#pathText">开始导入</el-button>
        <el-button size="small" @click="batchAddDialog = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 
      批量添加数据对话框
     -->
    <el-dialog class="sortClass" title="拖动排序" width='40%' :close-on-click-modal='false' :visible.sync="sortDialog">
      <avue-crud   :option="sortOption" 
                    :data="sortData"
                    ref="sortCrud"
                    v-model="sortForm"
                    @row-update="cloumnAddUpdate"
                    @sortable-change="cloumnSaveOrUpdate"
                    >
      </avue-crud>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" id="copyBtn" @click="handleImport($event)" data-clipboard-target="#pathText">开始导入</el-button>
        <el-button size="small" @click="sortDialog = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 历史记录 -->
    <update-history ref="historyRecord"></update-history>
  </basic-container>
</template>

<script>
import {queryBizApparchSceneListPage} from '@/api/biz/apparch/bizApparchSceneApi';

import {exportBizApparchBizFunctionExcel,saveOrUpdateBizApparchBizFunction,saveOrUpdateBizApparchBizFunctionList,saveBizApparchBizFunction,saveBizApparchBizFunctionList,deleteBizApparchBizFunction,queryBizApparchBizFunction,queryBizApparchBizFunctionListPage,updateBizApparchBizFunction,deleteBizApparchBizFunctionList} from '@/api/biz/apparch/bizApparchBizFunctionApi';
import {mapGetters} from 'vuex';
import { reqCommonMsg } from '@/util/reqCommonMsg';
import {filterFormat} from '@/util/util';
export default {
  props: {
    bizFunctionData: {
      type: Object,
      default: ''
    },
    functionType: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      //文件选择器的打开方式 add新增、edit修改、view 查看
      openType: 'edit',
      
      // 当前打开form对话框操作类型 
      operateType: 'add',
      
      //修改记录对话框
      historyDialog: false,
      //如果做流程表单 请将次开关设置为true，否则设置为false
      isFlow: true,
      flowArea: {},

      //排序设置
      sortDialog: false,
      sortForm: {},
      sortData: [],
      sortOption:{
        columnBtn: false,
        addBtn: false,
        delBtn: false,
        editBtn:false,
        viewBtn: false,
        refreshBtn: false,
        sortable:true,
        dragHandler:true,
        addBtn:false,
        menu:false,
        align:'center',
        column: [{
          label: '业务功能点编号',
          prop: 'bizFunctionNo',
        }, 
        {
          label: '业务功能点名称',
          prop: 'bizFunctionName', 
        }]
      },

      importDataArea: '',
      batchAddDialog: false,
      form: {},
      currentRow: {},
      selectionList: [],
      loading: true, 
      showColumn: [],
      option: {
        labelPosition: 'right',
        labelSuffix: '：',
        labelWidth: 125,
        dialogTop: '50',
        indexFixed:true, 
        stripe:true,
        calcHeight: 80,
        searchShow: true,
        searchBtn: true,
        searchMenuSpan: 12,
        tip: false,
        border: true,
        index: true,
        addBtn: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        cancelBtn: true,
        printBtn:false,
        saveBtn: true,
        filterBtn:false,
        columnBtn: false,          
        menuWidth: 120,
        dialogMenuPosition: 'center',
        dialogDirection:'rtl',
        dialogType:'dialog',
        dialogFullscreen:false,
        dialogClickModal:false,
        dialogWidth: '70%',
        highlightCurrentRow:  true,
        column: [
          
          
          {
            label: '业务场景编号',
            prop: 'bizSceneNo', 
            width:190,
            search: true,
            searchMmultiple: false,
            searchLabelWidth: 110,
            overHidden: true,
            span: 12,
            type: 'table',
            children: {
              border: true,
              column: [
                {
                  label: '需求名称',
                  prop: 'demandName', 
                  type: 'input', 
                  search: true
                },
                {
                  label: '产品名称',
                  prop: 'productName', 
                  type: 'input', 
                  search: true,
                },
                {
                  label: '业务场景编号',
                  prop: 'bizSceneNo', 
                  type: 'input', 
                  search: false,
                  searchLabelWidth: 110,
                },
                {
                  label: '业务场景名称',
                  prop: 'bizSceneName', 
                  type: 'input', 
                  search: true,
                  searchLabelWidth: 110,
                },
                {
                  label: '版本号',
                  prop: 'versionNo', 
                  type: 'input', 
                  search: false,
                  searchLabelWidth: 110,
                },
              ],
            },
            formatter: (row) => {
              if(row.bizFunctionNo) {
                return row.bizSceneNo;
              }
              else if(row.bizSceneNo){
                this.form.bizSceneName = row.bizSceneName;
                this.form.bizSceneNo = row.bizSceneNo;
                this.form.projectId = row.projectId;
                this.form.projectName = row.projectName;
                return row.bizSceneNo
              }
              else{
                return '';
              }
            },
            onLoad: ({ page, value,data }, callback) => {
              //首次加载去查询对应的值
              if (value) {
                //this.singleBody.projectId = this.projectInfo.id;
                this.reqParams =  {
                  singleBody: {
                    bizSceneNo: value
                  },
                  listBody: [{}],
                  sqlCondition: this.conditions,
                  orderRule: {
                    order: 'descending',
                    prop: 'versionNo'
                  },
                  currentPage: 1, 
                  pageSize: 10
                } 
                this.commonData = reqCommonMsg(this.reqParams)
                queryBizApparchSceneListPage(this.commonData).then(res => {
                  let returnData = [];
                  const data = res.data.body;
                  this.formPage.total = data.total;
                  data.listBody.forEach((element,index) => {
                    if(index == 0){
                      returnData = {
                        id: element.id,
                        bizSceneNo: element.bizSceneNo,
                        bizSceneName: element.bizSceneName,
                        demandName: element.demandName,
                        productName: element.productName,
                        versionNo: element.versionNo
                      }
                    }
                  });
                  callback(returnData)
                  return
                }, error => {
                });
                //callback()
                return
              }
              let searchValue = {};
              if(data){
                searchValue = data
              }
              if(page){
                this.formPage = page;
              }
              //分页查询信息
              
              //this.singleBody.projectId = this.projectInfo.id;
              this.reqParams =  {
                singleBody: searchValue,
                listBody: [{}],
                sqlCondition: this.conditions,
                orderRule: {
                  order: 'descending',
                  prop: 'versionNo'
                },
                currentPage: this.formPage.currentPage, 
                pageSize: this.formPage.pageSize
              }
              this.commonData = reqCommonMsg(this.reqParams)
              queryBizApparchSceneListPage(this.commonData).then(res => {
                let returnData = [];
                const data = res.data.body;
                this.formPage.total = data.total;
                data.listBody.forEach(element => {
                  returnData.push({
                    id: element.id,
                    bizSceneNo: element.bizSceneNo,
                    bizSceneName: element.bizSceneName,
                    demandName: element.demandName,
                    productName: element.productName,
                    versionNo: element.versionNo
                  })
                });
                callback({
                  total: this.formPage.total,
                  data: returnData
                })
                return
              }, error => {
              });
            },
            props: {
              label: 'bizSceneName',
              value: 'bizSceneNo'
            },
            rules: [
              {
                message: '请输入内容',
                required:  true,
              },
              {
                max: 30,
                message: '内容长度不能超过30字符',
              }
            ]
          },
          {
            label: '业务场景名称',
            prop: 'bizSceneName', 
            width:200,
            type: 'input', 
            search: true,
            searchMmultiple: false,
            searchLabelWidth: 120,
            multiple: false,
            span: 12,
            hide: false,
            maxlength: 50,
            overHidden: true,
            disabled: true,
            rules: [{
              message: '请输入内容',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '业务功能点编号',
            prop: 'bizFunctionNo', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 125,
            multiple: false,
            span: 12,
            width:190,
            hide: false,
            maxlength: 30,
            overHidden: true,
            display: false,
            rules: [{
              message: '请输入内容',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 30,
              message: '内容长度不能超过30字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '业务功能点名称',
            prop: 'bizFunctionName', 
            type: 'input', 
            search: true,
            searchMmultiple: false,
            searchLabelWidth: 125,
            multiple: false,
            span: 24,
            width:200,
            hide: false,
            maxlength: 50,
            overHidden: true,
            rules: [{
              message: '请输入内容',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 50,
              message: '内容长度不能超过50字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '业务功能点类型',
            prop: 'bizFunctionType', 
            type: 'select', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            hide: true,
            maxlength: 30,
            overHidden: true,
            rules: [{
              message: '请输入内容',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 30,
              message: '内容长度不能超过30字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '处理方式',
            prop: 'processWay', 
            type: 'select', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            hide: true,
            maxlength: 30,
            overHidden: true,
            rules: [{
              message: '请输入内容',
              required:  true,
              trigger: 'blur'
            },
            {
              max: 30,
              message: '内容长度不能超过30字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          
          {
            label: '业务序号',
            prop: 'bizSeq', 
            type: 'number', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            hide: true,
            overHidden: true,
            value: 0,
            maxRows:100,
            minRows:1,
            rules: [{
              message: '请输入内容',
              required:  false,
              trigger: 'blur'
            }],
            dicData:[],
          }, 
          {
            label: '变更日期',
            prop: 'changeDate', 
            type: 'date', 
            format:'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            pickerOptions: {
              disabledDate(time) {
                return time.getTime() + 3600 * 1000 * 24 <= Date.now();
              }
            },
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            hide: true,
            maxlength: 20,
            overHidden: true,
            showColumn: false,
            rules: [{
              message: '请输入内容',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 20,
              message: '内容长度不能超过20字符',
              trigger: 'blur'
            }],
            dicData:[]
          },
          
          {
            label: '版本号',
            prop: 'versionNo', 
            type: 'input', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            hide: false,
            maxlength: 30,
            overHidden: true,
            width:100,
            rules: [{
              message: '请输入内容',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 30,
              message: '内容长度不能超过30字符',
              trigger: 'blur'
            }],
            dicData:[],
          },
          {
            label: '资产标志',
            prop: 'assetFlag', 
            type: 'switch', 
            search: false,
            searchMmultiple: false,
            searchLabelWidth: 100,
            multiple: false,
            span: 12,
            hide: false,
            value: '0',
            maxlength: 1,
            overHidden: true,
            rules: [{
              message: '请输入内容',
              required:  false,
              trigger: 'blur'
            },
            {
              max: 1,
              message: '内容长度不能超过1字符',
              trigger: 'blur'
            }],
            dicData:[
              {
                label: '否',
                value: '0'
              },
              {
                label: '是',
                value: '1'
              }
            ],
          },
          {
            label: '标签信息',
            prop: 'labelInfo', 
            type: 'dynamic', 
            span: 24,
            children: {
              align: 'center',
              headerAlign: 'center', 
              column: [
                {
                  label: '标签类型',
                  prop: 'labelType',
                  type: 'select',
                  width: 120,
                  rules:[{
                    required:  true,
                    message: '请输入内容',
                  }],
                  dicData: [{
                    label: '测试',
                    value: '测试'
                  }, 
                  {
                    label: '通用',
                    value: '通用'
                  }]
                },
                {
                  label: '标签值',
                  prop: 'labelValues',
                  type: 'select',
                  multiple: true,
                  filterable: true,
                  rules: [{
                    type: 'array',
                    required: true,
                    message: '请输入内容',
                  }],
                  dicData:[],
                }, 
              ]
            }
          },
        ]
      },
      data: [],
      formPage: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      // 请求参数区
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      reqParams: {
        singleBody: {},
        listBody: [{}],
        sqlCondition:[],
        orderRule: [],
        currentPage: 1,
        pageSize: 10
      },
      commonData: null,
      conditions: [],
      orderRules: [],
      singleBody: {}
    };
  },
  computed: {
    ...mapGetters(['website','orgTree','genOrgTree','userInfo','permission','projectInfo']),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.biz_apparch_biz_function_add, false),
        viewBtn: this.vaildData(this.permission.biz_apparch_biz_function_view, false),
        delBtn: this.vaildData(this.permission.biz_apparch_biz_function_delete, false),
        editBtn: this.vaildData(this.permission.biz_apparch_biz_function_edit, false),
        printBtn: this.vaildData(this.permission.biz_apparch_biz_function_print, false),
        searchBtn:this.vaildData(this.permission.biz_apparch_biz_function_search, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push({id : ele.id});
      });
      return ids;
    } 
  },
  methods: {
    /**
     * 切换版本
     */
    changeBizFunctionVersion(row){
      this.$confirm('次操作将覆盖列表数据，确定要切换?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$emit('changeBizFunctionVersion',row);
      }).catch(() => {});
    },
    /**
     * 调用子组件添加记录
     */
    addToBizFunctionList(row){
      this.$emit('addToBizFunctionList',row);
    },
    
    /**
     * 加载列表数据
     */
    onLoad(page) {
      // 查看历史版本不显示需求和场景搜索条件
      if(this.functionType == 'version'){
        this.findObject(this.option.column, 'bizSceneNo').search = false;
        this.findObject(this.option.column, 'bizFunctionName').search = false;
        this.singleBody.bizFunctionNo = this.bizFunctionData.bizFunctionNo;
        this.singleBody.bizFunctionName = '';
      }
      else {
        this.findObject(this.option.column, 'bizSceneNo').search = true;
        this.findObject(this.option.column, 'bizFunctionName').search = true;
      }
      this.loading = true;
      this.orderRules = {
        order: 'descending',
        prop: 'versionNo'
      }
      this.reqParams =  {
        singleBody: this.singleBody,
        listBody: [{}],
        sqlCondition: this.conditions,
        orderRule: this.orderRules,
        currentPage: page.currentPage, 
        pageSize: page.pageSize
      }
      this.commonData = reqCommonMsg(this.reqParams)
      queryBizApparchBizFunctionListPage(this.commonData).then(res => {
        const data = res.data.body;
        this.page.total = data.total;
        this.data = data.listBody;
        this.loading = false;
        this.selectionClear();
      }, error => {
        this.loading = false; 
      });
    },
    /**
     * 新增一条记录
     */
    rowSave(row, done, loading) {
      this.reqParams.singleBody = row;
      let formatUser = {};
      this.commonData = reqCommonMsg(this.reqParams)
      saveBizApparchBizFunction(this.commonData).then(() => {
        done();
        this.singleBody={};
        this.onLoad(this.page);
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
      }, error => {
        //this.$console.log(error);
        done();
      });         
      //this.$console.log("row = ",row ,loading)
    },
    /**
     * 修改一条记录
     */
    rowUpdate(row, index, done, loading) {
      this.reqParams.singleBody = row;
      let formatUser = {};
      this.commonData = reqCommonMsg(this.reqParams)
      updateBizApparchBizFunction(this.commonData).then(() => {
        done();
        this.singleBody={}
        this.onLoad(this.page);
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
      }, error => {
        //this.$console.log(error);
        done();
      });
    },
    /**
     * 删除一条记录
     */
    rowDel(row) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.reqParams.singleBody = row;
          this.commonData = reqCommonMsg(this.reqParams);
          return deleteBizApparchBizFunction(this.commonData);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
        }).catch(() => {});
    },
    /**
     * 双击打开详细窗口
     */
    handleRowDBLClick (row, event) {
      if(this.permission.biz_apparch_biz_function_dbclick){
        this.$refs.crud.rowView(row,row.$index);
      }
    },
    /**
     * 批量新增记录
     */
    openBatchAddDialog(){
      this.batchAddDialog = true;
    },
    /**
     * 批量导入
     */
    handleImport() {
      const loading = this.$loading({
        lock: true,
        text: '处理中...',
        spinner: 'el-icon-loading',
      });
      var dataList = new Array();
      if(this.importDataArea){
        var lineList = this.importDataArea.split('\n')
        lineList.forEach((element,index) => {
          if(element.trim() != ''){
            var field = element.split('\t')
            var fieldList = {
              bizSceneNo:field[0].trim(),
              bizFunctionNo:field[1].trim(),
              versionNo:field[2].trim(),
              assetFlag:field[3].trim(),
              bizSceneName:field[4].trim(),
              bizFunctionName:field[5].trim(),
              bizFunctionType:field[6].trim(),
              processWay:field[7].trim(),
              bizSeq:field[8].trim(),
              bizFunctionDesc:field[9].trim(),
              changeDate:field[10].trim(),
              bizFunctionStatus:field[11].trim(),
            }
            dataList[index] = fieldList
            //this.$console.log('fieldList = ',fieldList)
          }
        });
        //批量写入记录
        this.reqParams.listBody = dataList;
        this.commonData = reqCommonMsg(this.reqParams)
        saveBizApparchBizFunctionList(this.commonData).then(() => {
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
          loading.close();
        }, error => {
          //this.$console.log(error);
          loading.close();
        });      
      }
      else{
        this.loading=false;
        this.$message({
          type: 'warning',
          message: '数据格式不正确!'
        });
      }
    },
    /**
     * 搜索重置
     */
    searchReset() {
      this.conditions =[];
      this.singleBody = {};
      this.onLoad(this.page);
    },
    /**
     * 搜索
     */
    searchChange(params, done) {
      this.singleBody = params
      this.page.currentPage = 1;
      this.onLoad(this.page);
      done();
    },
    refreshChange(){
      this.onLoad(this.page);
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    /**
     * 处理批量删除
     */
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据');
        return;
      }
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.reqParams.listBody = this.ids;
          this.commonData = reqCommonMsg(this.reqParams);
          return deleteBizApparchBizFunctionList(this.commonData);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
          this.$refs.crud.toggleSelection();
        }).catch(() => {});
    },
    /**
     * 拷贝记录
     */
    handleCopy(row){
      this.$confirm('确定复制数据?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.loading=true;
        let copyValue=row;
        copyValue.id='0';
        copyValue.dataSign='0'
        copyValue.tableName='拷贝 '+ copyValue.tableName; 
        this.reqParams.singleBody = copyValue;
        this.commonData = reqCommonMsg(this.reqParams)
        saveSysToolTables(this.commonData).then(() => {
          this.singleBody={};
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!'
          });
          this.loading=false;
        }, error => {
          //this.$console.log(error);
          this.loading=false;
        });
      }).catch(() => {});       
    },
    /**
     * 打开编辑、查询弹窗前查询记录
     */  
    beforeOpen(done, type) {
      if (['edit', 'view'].includes(type)) {
        this.operateType = 'edit';        
        this.reqParams =  {
          singleBody: {
            id:this.form.id
          }
        }
        let commonData = reqCommonMsg(this.reqParams)
        const loading = this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading'
        });
        queryBizApparchBizFunction(commonData).then(res => {
          this.form = res.data.body.singleBody;
          this.form.labelInfo = JSON.parse(this.form.labelInfo);
          loading.close();
          done();
        }, error => {
          //this.$console.log(error);
          loading.close();
          done();
        });
      }
      if (['add'].includes(type)) {
        this.operateType = 'add';        
        done();
      }
    },
    /**
     * 翻页查询
     */
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    /**
     * 更改每页条数
     */
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    /**
     * 自定义查询条件
     */
    filterChange(result) {
      this.page.currentPage = 1;
      this.conditions = filterFormat(result)
      this.onLoad(this.page);
    },
    /**
     * 列表排序
     */
    sortChange(val){
      this.orderRules=val
      this.onLoad(this.page);
    },
  
    /**
     * 导出Excel
     */
    exportExcel() {
      this.reqParams =  {
        singleBody: this.singleBody,
        listBody: [{}],
        sqlCondition: this.conditions,
        orderRule: this.orderRules,
        currentPage:1, 
        pageSize: 100
      }
      //this.$console.log('reqParams = ',this.reqParams)
      this.commonData = reqCommonMsg(this.reqParams)
      exportBizApparchBizFunctionExcel(this.commonData);
    },
    /**
     * 获取业务字典参数
     */
    async getBizDict() {
      let dicData = await this.$params.getBizDict('["bizFunctionType","processWay","labelType", "bizFunctionLabelValues"]');
      this.findObject(this.option.column, 'bizFunctionType').dicData = dicData.bizFunctionType;
      this.findObject(this.option.column, 'processWay').dicData = dicData.processWay;
      this.findObject(this.option.column, 'labelInfo').children.column[0].dicData = dicData.labelType;
      this.findObject(this.option.column, 'labelInfo').children.column[1].dicData = dicData.bizFunctionLabelValues;
    },
    
    /**
     * 调用子组件方法查询历史
     */
    getHistoryRecord () {
      setTimeout(() => {
        this.$refs.historyRecord.getUpdateHistoryRecord(this.form.id);
      })
    },
  },
  created() {
    //如果和项目相关，请打开
    // if(!this.projectInfo || !this.projectInfo.projectName){
    //   this.$message({
    //     type: 'warning',
    //     message: '请选择一个项目再进入！'
    //   });
    //   this.$router.push({path: '/general/project/generalMyProjectSelector'});
    // }       
    this.showColumn = this.$getStore({name: this.userInfo.userId+'bizApparchBizFunctionColumn'});
    //获取业务字典
    setTimeout(() => {
      this.getBizDict();
    }, 1000);
    
    //加载机构
    let getOrgTreeTimer = setInterval(() => {
      if(this.genOrgTree){
        let orgTree = [];
        this.genOrgTree.forEach(element => {
          if(element.orgType == '1'){
            orgTree.push(element);
          }
        });
        clearInterval(getOrgTreeTimer);
      }
    }, 100);
  },
  watch: {
    showColumn: {
      handler(newValue, oldValue) {
        this.$setStore({name:  this.userInfo.userId+'bizApparchBizFunctionColumn', content: this.showColumn});
      },
      deep: true
      //this.$setStore({name:  this.userInfo.userId+'bizApparchBizFunctionColumn', content: this.showColumn});
    },
    bizFunctionData: {
      handler (val) {
        this.singleBody={};
        this.onLoad(this.page);
      },
      deep: true
    },
    functionType:{
      handler (val) {
      },
      deep: true
    }
  }
};
</script>
<style>
.sortClass .avue-crud__menu{
   display: none !important;
 }
.sortClass .avue-crud__pagination{
   padding:5px !important;
   margin: 0px !important;
 }
</style>